/**
 * Handler1.java is created by Zachariah at 2012-2-3 下午05:54:45
 */
package com.zack.designPattern.chain;

/**
 * @author zachariah zzcfrog@gmail.com
 *
 */
public class Handler1 implements Handler {

	private Handler nextHandler;
	
	private String condition;
	
	public Handler1(String condition, Handler nextHandler){
		this.condition = condition;
		this.nextHandler = nextHandler;
	} 
	/**
	 * @see com.zack.designPattern.chain.Handler#handle(java.lang.String)
	 */
	@Override
	public void handle(String condition) {
		if(condition==null || !condition.equals(this.condition)){
			if(this.nextHandler!=null){
				this.nextHandler.handle(condition);
			}else{
				System.out.println("no handler deals it, failed");
			}
		}else{
			System.out.println(this.condition+" handler deals it");
		}

	}

	/**
	 * @see com.zack.designPattern.chain.Handler#setNextHandler(com.zack.designPattern.chain.Handler)
	 */
	@Override
	public void setNextHandler(Handler handler) {
		// TODO Auto-generated method stub

	}

}
